package org.openkanban.shared.dto;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.openkanban.client.ui.presenter.RequestParameterMap;
import org.openkanban.client.util.JsonConverter;

/**
 * Data Transfer Object used for transferring Board information
 */
public class BoardDto extends TransferObject implements RequestParameterMap {

    private Long boardId;

    private String boardName;

    private Set<ActivityDto> activities;

    private Set<UserDto> boardUser;

    public BoardDto() {
    }

    public BoardDto(String json) {
	boardId = JsonConverter.getLongValueOrNull(json, "boardId");
	boardName = JsonConverter.getStringValueOrNull(json, "boardName");
	activities = JsonConverter.getObjectsAsSet(json, "activities", ActivityDto.class);
	boardUser = JsonConverter.getObjectsAsSet(json, "boardUser", UserDto.class);
    }

    public Long getBoardId() {
	return boardId;
    }

    public void setBoardId(Long boardId) {
	this.boardId = boardId;
    }

    public String getBoardName() {
	return boardName;
    }

    public void setBoardName(String boardName) {
	this.boardName = boardName;
    }

    public Set<ActivityDto> getActivities() {
	return activities;
    }

    public void setActivities(Set<ActivityDto> activities) {
	this.activities = activities;
    }

    public Set<UserDto> getBoardUser() {
	return boardUser;
    }

    public void setBoardUser(Set<UserDto> boardUser) {
	this.boardUser = boardUser;
    }

    @Override
    public Map<String, String> valuesToMap() {
	Map<String, String> requestParameterMap = new HashMap<String, String>();
	if (boardId != null) {
	    requestParameterMap.put("boardId", Long.toString(boardId));
	}
	requestParameterMap.put("boardName", boardName);
	return requestParameterMap;
    }

}
